/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package managerBeanAdmin;

import entity.Complaint;
import entity.Solution;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;

import javax.faces.bean.SessionScoped;
import managerBeanViews.Login;
import processor.SolutionFacade;

/**
 *
 * @author maynoigi
 */
@ManagedBean
@SessionScoped
public class SolutionBean implements Serializable {

    @EJB
    private SolutionFacade solutionFacade;
    Complaint complaintSelected;
    List<Solution> solution;
    List<Solution> flitterSolution;
    private String solutionContent;
    private Solution solutionSelected = new Solution();

    public Solution getSolutionSelected() {

        return solutionSelected;
    }

    public void setSolutionSelected(Solution solutionSelected) {
        this.solutionSelected = solutionSelected;
    }

    public String getSolutionContent() {
        solutionContent = solutionSelected.getSolutionContent();
        return solutionContent;
    }

    public void setSolutionContent(String solutionContent) {
        this.solutionContent = solutionContent;
    }
    @ManagedProperty(value = "#{login}")//this is EL name of your bean 
    private Login injectedBean;
    String alert = "aa";

    public Login getInjectedBean() {
        return injectedBean;
    }

    public void setInjectedBean(Login injectedBean) {
        this.injectedBean = injectedBean;
    }

    public String getAlert() {
        return alert;
    }

    public void setAlert(String alert) {
        this.alert = alert;
    }

    public List<Solution> getFlitterSolution() {
        return flitterSolution;
    }

    public void setFlitterSolution(List<Solution> flitterSolution) {
        this.flitterSolution = flitterSolution;
    }

    public Complaint getComplaintSelected() {
        return complaintSelected;
    }

    public void setComplaintSelected(Complaint complaintSelected) {
        this.complaintSelected = complaintSelected;
    }

    public List<Solution> getSolution() {
        solution = solutionFacade.getSolutionByComplaintsID(complaintSelected);
        return solution;
    }

    public void setSolution(List<Solution> solution) {
        this.solution = solution;
    }

    public SolutionBean() {
    }

    public String direction(Complaint temp) {
        String a = temp.getComplaintContent();
        this.complaintSelected = temp;
        return "solution.xhtml";

    }

    public void deleteSolution(Solution solution) {
        solutionFacade.deleteSolution(solution);
    }

    public void editSolution(Solution solution) {
        alert = "Edit Solution Successfull";

        solution.setMembersID(injectedBean.getCustomer());
        solution.setSolutionContent(solutionContent);
        solution.setSolutionCreateDate(new Date());
        solutionFacade.edit(solution);



    }



   public void closeDialog() {
        alert = "aa";
    }
}
